﻿
@{
    ViewData["Title"] = "UptRoomView";

}

<link href="~/css/bootstrap.css" rel="stylesheet" />
<script src="~/js/axios.min.js"></script>
<script src="~/js/vue.js"></script>
<script src="~/js/qs.min.js"></script>
<h3 style="color:cornflowerblue">修改客房类型</h3>
<hr />
<div class="row" id="app">
    <table class="table table-bordered">
        <tr>
            <td>客房名称</td>
            <td><input id="name" type="text"></td>
        </tr>
     
        <tr>
            <td>客房价格</td>
            <td><input id="price" type="text"></td>
        </tr>
        <tr>
            <td>客房状态</td>
            <td>
                <input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked>已入住
                <input type="radio" name="optionsRadios" id="optionsRadios1" value="option2">未入住
            </td>
        </tr>
        <tr>
            <td>客房电话</td>
            <td><input id="tel" type="text"></td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button" v-on:click="UptHob" value="修改" class="btn btn-success">
            </td>
        </tr>
    </table>
</div>

<script>
    new Vue({
        el:'#app',
        data() {
            return {
                r:[],
            }

        },
        mounted: function () {        //页面加载成功的事件
            this.id = location.search.substring(location.search.indexOf("=") + 1);
            //设置请求路径
            axios
                .get("/Room/RoomsModels",{
                    params: {
                        rid: this.id
                    }
                })
                .then(function (i) {
                    $("#name").val(i.data.Rname);
                    $("#price").val(i.data.Rprice);
                    $("#optionsRadios1").val(i.data.Rstate);
                    $("#tel").val(i.data.Rtel);
                })
        },
        methods: {  //修改
            UptHob: function () {
                this.id = location.search.substring(location.search.indexOf("=") + 1);
                alert("修改成功");
                location.href = '/Room/RoomsShow';
                var obj = {};
                obj.Rname =  $("#name").val();
                obj.RTname = $("#style").val();
                obj.Rprice = $("#price").val();
                obj.Rstate = $("#optionsRadios1").val();
                obj.Rtel   =   $("#tel").val();
                axios
                    .post("/Room/UptRoom",window.Qs.stringify(obj))
                    .then(
                        function (i) {
                            if (i.data > 0) {
                                alert("修改成功");
                                location.href = '/Room/RoomsShow';
                            }
                            else {
                                alert("修改失败");
                            }
                        }
                    )
            }
        }

    })
</script>

